package com.ljy.my_study.util;

/**
 * @author lijunying
 * @date 2021/1/15 14:33
 */
public class ArrayUtil {

    public static int[][] changeStr2Array(String str){
//        [[0,0],[0,1],[1,0],[1,2],[2,1],[2,2]]
        String[] array=str.substring(2,str.length()-2).split("],\\[");
        int[][] result=new int[array.length][];
        for(int i=0;i<array.length;i++){
            String s=array[i].trim();
            if("".equals(s)){
                result[i]=new int[0];
            }else{
                String[] sub=s.split(",");
                result[i]=new int[sub.length];
                for(int j=0;j<sub.length;j++){
                    result[i][j]=Integer.valueOf(sub[j]);
                }
            }
        }
        return result;
    }
}
